<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>planet</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="pitchamdf.html" title="pitchamdf" />
    <link rel="next" href="platerev.html" title="platerev" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">planet</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="pitchamdf.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="platerev.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="planet"></a>
      <div class="titlepage"></div>
      <a id="IndexPlanet" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">planet</span>
        </h2>
        <p>planet — 
      Simulates a planet orbiting in a binary star system.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp134572816"></a>
        <h2>Description</h2>
        <p>
      <span class="emphasis"><em>planet</em></span> simulates a planet orbiting in a binary star system. The outputs are the x, y and z coordinates of the orbiting planet. It is possible for the planet to achieve escape velocity by a close encounter with a star. This makes this system somewhat unstable.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp134574624"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ax, ay, az <span class="command"><strong>planet</strong></span> kmass1, kmass2, ksep, ix, iy, iz, ivx, ivy, ivz, idelta \
      [, ifriction] [, iskip]</pre>
      </div>
      <div class="refsect1">
        <a id="idp134576752"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ix, iy, iz</em></span> -- the initial x, y and z coordinates of the planet
    </p>
        <p>
      <span class="emphasis"><em>ivx, ivy, ivz</em></span> -- the initial velocity vector components for the planet.
    </p>
        <p>
      <span class="emphasis"><em>idelta</em></span> -- the step size used to approximate the differential equation.
    </p>
        <p>
      <span class="emphasis"><em>ifriction</em></span> (optional, default=0) -- a value for friction, which can be used to keep the system from blowing up
    </p>
        <p>
      <span class="emphasis"><em>iskip</em></span> (optional, default=0) -- if non zero
    skip the initialisation of the filter. (New in Csound version
    4.23f13 and 5.0)
    </p>
      </div>
      <div class="refsect1">
        <a id="idp134581936"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ax, ay, az</em></span> -- the output x, y, and z coodinates of the planet
    </p>
        <p>
      <span class="emphasis"><em>kmass1</em></span> -- the mass of the first star
    </p>
        <p>
      <span class="emphasis"><em>kmass2</em></span> -- the mass of the second star
    </p>
      </div>
      <div class="refsect1">
        <a id="idp134585312"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the planet opcode. It uses the file <a class="ulink" href="examples/planet.csd" target="_top"><em class="citetitle">planet.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp134587168"></a>
          <p class="title">
            <strong>Example 631. Example of the planet opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o planet.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="comment">; Initialize the global variables.</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">kr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 1
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="comment">; Instrument #1 - a planet oribiting in 3D space.</span>
<span class="oblock">instr</span> 1
  <span class="comment">; Create a basic tone.</span>
  kamp <span class="opc">init</span> 5000
  kcps <span class="opc">init</span> 440
  ifn <span class="op">=</span> 1
  asnd <span class="opc">oscil</span> kamp, kcps, ifn

  <span class="comment">; Figure out its X, Y, Z coordinates.</span>
  km1 <span class="opc">init</span> 0.5
  km2 <span class="opc">init</span> 0.35
  ksep <span class="opc">init</span> 2.2
  ix <span class="op">=</span> 0
  iy <span class="op">=</span> 0.1
  iz <span class="op">=</span> 0
  ivx <span class="op">=</span> 0.5
  ivy <span class="op">=</span> 0
  ivz <span class="op">=</span> 0
  ih <span class="op">=</span> 0.0003
  ifric <span class="op">=</span> <span class="op">-</span>0.1
  ax1, ay1, az1 <span class="opc">planet</span> km1, km2, ksep, ix, iy, iz, \
                       ivx, ivy, ivz, ih, ifric

  <span class="comment">; Place the basic tone within 3D space.</span>
  kx <span class="opc">downsamp</span> ax1
  ky <span class="opc">downsamp</span> ay1
  kz <span class="opc">downsamp</span> az1
  idist <span class="op">=</span> 1
  ift <span class="op">=</span> 0
  imode <span class="op">=</span> 1
  imdel <span class="op">=</span> 1.018853416
  iovr <span class="op">=</span> 2
  aw2, ax2, ay2, az2 <span class="opc">spat3d</span> asnd, kx, ky, kz, idist, \
                            ift, imode, imdel, iovr

  <span class="comment">; Convert the 3D sound to stereo.</span>
  aleft <span class="op">=</span> aw2 <span class="op">+</span> ay2
  aright <span class="op">=</span> aw2 <span class="op">-</span> ay2

  <span class="opc">outs</span> aleft, aright
<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="comment">; Table #1 a sine wave.</span>
<span class="stamnt">f</span> 1 0 16384 10 1

<span class="comment">; Play Instrument #1 for 10 seconds.</span>
<span class="stamnt">i</span> 1 0 10
<span class="stamnt">e</span>


<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp134591456"></a>
        <h2>See Also</h2>
        <p> More information on this opcode: <a class="ulink" href="http://www.csoundjournal.com/issue9/FlutesInOrbit.html" target="_top"><em class="citetitle">http://www.csoundjournal.com/issue9/FlutesInOrbit.html</em></a>  , written by Brian Redfern. </p>
      </div>
      <div class="refsect1">
        <a id="idp134593632"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Hans Mikelson</td>
          </tr>
          <tr>
            <td>December 1998</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 3.50</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="pitchamdf.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="platerev.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">pitchamdf </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> platerev</td>
        </tr>
      </table>
    </div>
  </body>
</html>
